<template>
	<view class="content">
		<view class="card">
			<view class="title">
				<image src="/static/order/fapiao_content.png"></image>
				<text>发票详情</text>
			</view>
			<view class="list">
				<view class="label">抬头类型</view>
				<view class="checkbox">
					<view class="item" @click="isckecked = 1">
						<uni-icons type="checkbox-filled" :size="24" color="#EF5233" v-if="isckecked == 1"></uni-icons>
						<uni-icons type="circle" :size="24" color="#989898" v-else></uni-icons>
						<text>企业单位</text>
					</view>
					<view class="item"  @click="isckecked = 2">
						<uni-icons type="checkbox-filled" :size="24" color="#EF5233" v-if="isckecked == 2"></uni-icons>
						<uni-icons type="circle" :size="24" color="#989898" v-else></uni-icons>
						<text>个人/非企业单位</text>
					</view>
				</view>
			</view>
			<view class="list">
				<view class="label">公司名称</view>
				<input type="text" placeholder="请输入公司名称" class="inp" v-model="info.name">
			</view>
			<view class="list">
				<view class="label">公司税号</view>
				<input type="text" placeholder="请输入税号" class="inp" v-model="info.code">
			</view>
			<!-- <view class="list no_border">
				<view class="label">公司税号</view>
				<view class="more flex_r_between">
					<text></text>
					<view class="right">
						<text>共5项 已填写4项</text>
						<uni-icons type="forward" :size="20" color="#989898"></uni-icons>
					</view>
				</view>
			</view> -->
		</view>
		
		<view class="card" style="margin: 30rpx 0;padding-top: 0;">
			<view class="list no_border">
				<view class="label">总金额</view>
				<view class="more flex_r_between">
					<text class="left"><i>{{priceData}}</i> 元</text>
					<!-- <view class="right">
						<text>共1张，查看详情</text>
						<uni-icons type="forward" :size="20" color="#989898"></uni-icons>
					</view> -->
				</view>
			</view>
		</view>
		
		<view class="card">
			<view class="title">
				<image src="/static/order/fapiao_type.png"></image>
				<text>接收方式</text>
			</view>
			<view class="list">
				<view class="label">电子邮箱</view>
				<input type="text" placeholder="请输入邮箱" class="inp" v-model="info.e_mail">
			</view>
		</view>
		
		<view class="btn flex_r_around" @click="saveInvoice">
			<view>立即开票</view>
		</view>
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				info:{
					name:'',
					code:'',
					e_mail:'',
				},
				ids:'',
				priceData:"",
				isckecked:1,
			}
		},
		onLoad(option) {
			this.ids = option.ids
			this.resdNum()
		},
		methods: {
			resdNum(){
				var that = this
				this.request.httpTokenRequest({
					url: "order/getInvoiceOrderPrice",
					method: "POST"
				},{
					order_ids: this.ids
				}).then(function(res) {
					if (res.code == 0) {
						that.priceData = res.data.price
					} else {
					}
				})
			},
			saveInvoice(){
				var that = this
				this.request.httpTokenRequest({
					url: "order/saveInvoice",
					method: "POST"
				},{
					order_ids:this.ids,
					price: this.priceData,
					type: this.isckecked,
					name: this.info.name,
					shuihao:this.info.code,
					email:this.info.e_mail
				}).then(function(res) {
					if (res.code == 0) {
						that.$util.msg(res.msg)
						setTimeout(function(){
							uni.navigateTo({
								url:'/otherpages/order/invoice/list'
							})
						},1500)
					} else {
						that.$util.msg(res.msg)
					}
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.content {
		padding: 30rpx 30rpx 120rpx;
		box-sizing: border-box;
	}
	.card {
		padding: 30rpx 30rpx 0;
		background: #FFFFFF;
		border-radius: 10rpx;
		.title {
			display: flex;
			align-items: center;
			image {
				width: 30rpx;
				height: 30rpx;
				margin-right: 10rpx;
			}
			text {
				font-size: 30rpx;
				font-weight: 600;
				color: #EF5233;
				line-height: 42rpx;
			}
		}
		.list {
			display: flex;
			align-items: center;
			padding: 28rpx 0;
			border-bottom: 1rpx solid #E8E8E8;
			.label {
				width: 130rpx;
				margin-right: 30rpx;
				font-size: 30rpx;
				color: #333333;
				line-height: 42rpx;
			}
			.checkbox {
				display: flex;
				align-items: center;
				.item {
					display: flex;
					align-items: center;
					text {
						font-size: 28rpx;
						color: #676869;
						line-height: 40rpx;
						margin-left: 12rpx;
					}
				}
			}
			.inp {
				flex: 1;
				font-size: 28rpx;
				color: #676869;
				line-height: 40rpx;
			}
			.more {
				flex: 1;
				.right {
					font-size: 28rpx;
					color: #989898;
					line-height: 40rpx;
					display: flex;
					align-items: center;
				}
				.left {
					font-size: 30rpx;
					line-height: 42rpx;
					color: #333333;
					i {
						color: #EF5233;
						font-style: normal;
					}
				}
			}
		}
	}

	.btn {
		width: 100vw;
		position: fixed;
		bottom: 0;
		z-index: 99;
		left: 0;
		height: 120rpx;
		background: #FEFFFF;
		border-radius: 8rpx;
		view {
			width: 689rpx;
			height: 88rpx;
			background: #EF5233;
			border-radius: 44rpx;
			font-size: 34rpx;
			color: #FFFFFF;
			line-height: 88rpx;
			text-align: center;
		}
	}

</style>
